home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17008 < prev    next >
Encoding:
Text File  |  1996-08-05  |  974 b   |  41 lines

  1. Path: news.Stanford.EDU!usenet
  2. From: Nick Cassimatis <nick@psych.stanford.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Default Constructors
  5. Date: Fri, 12 Apr 1996 21:20:24 -0700
  6. Organization: Stanford University
  7. Message-ID: <316F2B88.5FC4@psych.stanford.edu>
  8. NNTP-Posting-Host: nick.stanford.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win95; I)
  13.  
  14. I'm having trouble getting default constructors to work in another 
  15. class' constructor: e.g.,
  16.  
  17. class position {
  18.     int x,y,z;
  19.     position() {x = y = z = 0;};
  20.     position(int, int, int);
  21. };
  22.  
  23. class object {
  24.     position pos;
  25.     object();
  26. };
  27.  
  28. object::object() {
  29.     pos.x = 1;
  30. }
  31.  
  32. I get the following error messages (in BC4.5):
  33.  
  34. 'position::position()' is not accessible in function object::object()
  35. 'position::x' is not accessible in function object::object()
  36.  
  37. What exactly is meant by "access"? And why wouldn't I have it to an 
  38. object that's already been declared?
  39.  
  40. -Nick
  41.